<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/12
 * Time: 19:37
 */

class Score extends WX_Controller
{

    /**
     * 初始化
     * Score constructor.
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 列表
     */
    public function getUserScore()
    {
        if (!empty($this->openId)) {

            $result = [];
            $this->load->model('wx/user/User_Model', 'user');
            $ret = $this->user->getScoreRecord($this->userid);
            if (!empty($ret)) foreach ($result as $item) {
                $result[] = [
                    'score' => intval($item['score']),
                    'type' => value($item, 'type', ''),
                    'orderid' => intval($item['orderid']),
                    'amount' => intval($item['amount']),
                    'amount_format' => money_format('%i', $item['amount'] / 100),
                    'note' => value($item, 'note', ''),
                    'created' => value($item, 'created', '')
                ];
            }

            $this->output($result);

        } else {
            $this->outputError(self::NO_LOGIN);
        }
    }

}